package org.example.sword2offer.primary;

import java.util.Arrays;

/**
 * @author: lynn
 * @Descript:
 * @date: 2021/8/15 9:50
 * @version: 1.0
 */
public class Q92_MaoPaoSort {
    public static void main(String[] args) {
        int[] nums={1,3,4,8,2,5,9,6};
        Q92_MaoPaoSort mp=new Q92_MaoPaoSort();
        mp.bubleSort(nums);
        System.out.println(Arrays.toString(nums));
    }

    private void bubleSort(int[] nums){
        for (int i=0;i<nums.length;i++){
            //fixme 边界缩小-1，然后比较附近的两个值
            for (int j=0;j<nums.length-i-1;j++){
                if (nums[j]>nums[j+1]){
                    int tmp=nums[j];
                    nums[j]=nums[j+1];
                    nums[j+1]=tmp;
                }
            }
        }
    }
}
